﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Fashion.Models.Interface;

namespace Fashion.Models
{
    public class AccountRepository : IAccountRepository
    {
        public DALDataContext D;

        public AccountRepository()
        {
            D = new DALDataContext();
        }
        
        public void AddNewAccount(Account account)
        {
            D.Accounts.InsertOnSubmit(account);
            D.SubmitChanges();
        }

        public void UpdateAccount(Account account)
        {
            
        }

        public Account FindAccountByUserName(string username)
        {
            return D.Accounts.FirstOrDefault(i => i.UserName.Equals(username));
        }

        public Account Login(string username, string password)
        {
            return D.Accounts.FirstOrDefault(i => i.UserName.Equals(username) && i.Password.Equals(password));
        }

        public Account GetAccountById(int id)
        {
            return D.Accounts.FirstOrDefault(i => i.Id == id);
        }
    }
}